package optimizations.parser.SyntaxTree;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import execution.Tape;

import optimizations.lexer.Position;

public abstract class AbstractSyntaxNode {

	public Position position() {
		return position;
	}

	public List<AbstractSyntaxNode> getChildren() {
		return children;
	}

	private final Position position;
	private final List<AbstractSyntaxNode> children;

	public AbstractSyntaxNode(Position position, AbstractSyntaxNode... children) {
		this.position = position;
		this.children = Arrays.asList(children);
	}

	public AbstractSyntaxNode(Position position,
			Collection<? extends AbstractSyntaxNode> children) {
		this.position = position;
		this.children = Collections.unmodifiableList((List<? extends AbstractSyntaxNode>) children);
	}

	public abstract void execute(Tape tape) throws IOException;

}
